package com.tianji.learning.controller;

import com.tianji.common.domain.dto.PageDTO;
import com.tianji.learning.domain.query.AdminNotesQuery;
import com.tianji.learning.domain.vo.AdminNoteVo;
import com.tianji.learning.domain.vo.AdminNotesPageVo;
import com.tianji.learning.service.INoesService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/admin/notes")
@Api(tags = "管理端学习笔记相关接口")
@RequiredArgsConstructor
public class AdminNoesController {
    private final INoesService noesService;

    /**
     * 管理端笔记分页查询
     * @param query
     * @return
     */
    @GetMapping("/page")
    @ApiOperation(value = "管理端笔记分页查询")
    public PageDTO<AdminNotesPageVo> adminQueryNotesPage(AdminNotesQuery query){
        return noesService.adminQueryNotesPage(query);
    }

    /**
     * 管理端笔记详情
     */
    @GetMapping("/{id}")
    @ApiOperation(value = "管理端笔记详情")
    public AdminNoteVo adminQueryNote(@PathVariable("id") Long id){
        return noesService.adminQueryNote(id);
    }

    /**
     * 隐藏或显示笔记
     * @param id
     * @param hidden
     */
    @PutMapping("/{id}/hidden/{hidden}")
    @ApiOperation(value = "隐藏或显示笔记")
    public void hiddenOrNoHiddenNote(@PathVariable("id") Long id, @PathVariable("hidden") Boolean hidden){
        noesService.hiddenOrNoHiddenNote(id, hidden);
    }
}
